let chartDataStr=decodeHtml(chartData);
let chartJsonArray=JSON.parse(chartDataStr);

let arrayLength=chartJsonArray.length;
let numericData=[];
let labelData=[];

for (let i=0;i<arrayLength;i++){
    numericData[i]=chartJsonArray[i].value;
    labelData[i]=chartJsonArray[i].label;
}

const data = {
    labels:labelData,
    datasets: [{
        type: 'bar',
        label: 'Bar Dataset',
        data: numericData,
        borderColor: 'rgb(255, 99, 132)',
        backgroundColor: [
            'rgba(255, 205, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(153, 102, 255, 0.2)'
        ]
    }, {
        type: 'line',
        label: 'Line Dataset',
        data: [10, 10, 10, 10],
        fill: false,
        borderColor:  [
            'rgb(255, 205, 86)',
            'rgb(75, 192, 192)',
            'rgb(54, 162, 235)',
            'rgb(153, 102, 255)'
        ]
    }]
};

const options={
    plugin: {
        title:{
            display:true,
            text:"商品类型"
        }
    }
}

//条形图

new Chart(document.getElementById("myChart"),{
    type:'bar',
    data: data,
    options: options
})

function decodeHtml(html){
    let txt=document.createElement("textarea");
    txt.innerHTML=html;
    return txt.value;
}